package hsintiao.com.xintiaoAPP.service.impl;

import hsintiao.com.xintiaoAPP.entity.PayBill;
import hsintiao.com.xintiaoAPP.mapper.TestMapper;
import hsintiao.com.xintiaoAPP.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class TestServiceImpl implements TestService {

    @Autowired
    private TestMapper mapper;
    @Override
    //@Async("asyncServiceExecutor")
    @Transactional
    public PayBill insert(PayBill payBill) {
        try {
            Long id=51L;
            mapper.insert(payBill);
            System.out.println("插入成功");
            Thread.sleep(10000);
            Long id1 = payBill.getId();
            PayBill payBillGet = mapper.select(id1);
            payBillGet.setSeller_id("2011002312");
            mapper.update(payBillGet);
            System.out.println("线程获取="+payBillGet);
            return payBillGet;
        }catch (Exception e){
            e.printStackTrace();
            throw new RuntimeException("出错");
        }
    }

    @Override
    public PayBill selsect(Long id) {
        try {
            Thread.sleep(9000);
            PayBill select = mapper.select(id);
            System.out.println("获取="+select);
            return select;
        } catch (InterruptedException e) {
            e.printStackTrace();
            return null;
        }
    }
}
